// Fill out your copyright notice in the Description page of Project Settings.


#include "EnemyBaseCharacter.h"

#include "MyGameInstance.h"
#include "PlayCharacter.h"
#include "Components/CapsuleComponent.h"
#include "Kismet/GameplayStatics.h"

// Sets default values
AEnemyBaseCharacter::AEnemyBaseCharacter()
{
	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
}

// Called when the game starts or when spawned
void AEnemyBaseCharacter::BeginPlay()
{
	Super::BeginPlay();
}

// Called every frame
void AEnemyBaseCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

// Called to bind functionality to input
void AEnemyBaseCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);
}

void AEnemyBaseCharacter::ClickEvent(UPrimitiveComponent* PrimComp, FKey InKey)
{
	UE_LOG(LogTemp, Log, TEXT("我被点击了"));
	APlayCharacter* MyCharacter = Cast<APlayCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));
	if (MyCharacter->SelectActor != this)
	{
		MyCharacter->SelectActor = this;
		UMyGameInstance* inst = Cast<UMyGameInstance>(GetGameInstance());
		inst->SelectEnemy(this);
	}
}

